package control;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @author LYM
 *
 */
public class Ping {
	
	
	/** Teste la connection à un host distant
	 * @param host host distant
	 * @param timeOut time out en milliseconde
	 * @return true si l'host est joignable
	 */
	public static boolean ping(String host, int timeOut){
		boolean result= false;
		try {
			result= InetAddress.getByName(host).isReachable(timeOut);
		} catch (UnknownHostException e) {
			System.out.println(e);
		} catch (IOException e) {
			System.out.println(e);
		}
		return result;
	}
	/**
	 * @param args
	 */
	public static void main(String args[]){
		final String host= "192.168.78.128";
		int timeOut= 3000;
		System.out.println(ping(host, timeOut));
		System.out.println(ping("melofee.enseeiht.fr", 3000));
	}
}
